package com.keya.features.operations;

import com.keya.base.sh.RunShell;
import com.keya.base.sh.RunShellRet;
import io.micrometer.core.instrument.Metrics;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class StoreScuOp {
    private String host;

    private String port;

    private String source;

    // self
    private String aet;

    // peer
    private String aec;

    private String desc;

    private Integer timeout;

    public RunShellRet run() throws Exception {
        return Metrics.timer("op_storescu").recordCallable(this::runShellRet);
    }

    public RunShellRet runShellRet() throws Exception {
        String bash = String.format("storescu %s %s -aet %s -aec %s -v +sd +r -xy -nh %s 2>&1", host
                , port, aet, aec, source);
        String[] cmds = {"bash", "-c", bash};
        return RunShell.runShell(desc, cmds, timeout);
    }
}
